$(function() {
	// 验证码点击刷新
	$("#Verify").click(function() {
		refreshSecurityCodeImage();
		setTimeout("getSecurityCode()", 1000);

	});
	
	setTimeout("getSecurityCode()", 3000);
});

// 刷新验证码图片
var securityCode = "";
function refreshSecurityCodeImage() {
	$("#Verify").attr("src",
			"securityCodeImage?timestamp=" + new Date().getTime());
}

// 通过cookie获取验证码字符串
function getSecurityCode() {
	// $.getJSON("getSecurityCode?timestamp=" + new Date().getTime(),
	// function(result) {
	// securityCode = result.securityCode; });
	if (document.cookie.length > 0) {
		var c_name = "securityCode";
		c_start = document.cookie.indexOf(c_name + "=");
		if (c_start != -1) {
			c_start = c_start + c_name.length + 1;
			c_end = document.cookie.indexOf(";", c_start);
			if (c_end == -1)
				c_end = document.cookie.length;
			securityCode = unescape(document.cookie.substring(c_start, c_end));
			// alert(securityCode);
		}
	}
}